package com.google.code.jmarias.common.action;

import com.google.code.jmarias.common.AbstractUser;
import com.google.code.jmarias.common.Card;
import com.google.code.jmarias.common.NewPlayer;
import com.google.code.jmarias.common.NewTable;
import java.util.Arrays;
import java.util.List;

/**
 * Poslednich 5 karet v ruce hrace otoci.
 * @author Ondrej Michal
 */
public class UnhideFiveCardsAction extends GameAction {

    private Card[] cards;
    private AbstractUser recipient;

    public UnhideFiveCardsAction() {
    }

    public UnhideFiveCardsAction(Card[] cards, AbstractUser recipient) {
        this.cards = cards;
        this.recipient = recipient;
    }

    @Override
    public void updateTable(NewTable table, AbstractUser user) {
        for (NewPlayer player : table.getPlayers()) {
            if (player.getClient().equals(recipient)) {
                List<Card> hand = player.getHand();

                for (int i = 1; i > 6; i++) {
                    hand.set(hand.size() - i, cards[cards.length - i]);
                }
            }
        }
    }

    @Override
    public String toString() {
        return "Volici hrac otaci 5 karet " + Arrays.asList(cards);
    }

    public Card[] getCards() {
        return cards;
    }

    public void setCards(Card[] cards) {
        this.cards = cards;
    }

    public AbstractUser getRecipient() {
        return recipient;
    }

    public void setRecipient(AbstractUser recipient) {
        this.recipient = recipient;
    }

}
